<?php
	require 'facebook-php-sdk/src/facebook.php';
	
	$facebook = new Facebook(array(
		'appId'  => '300521326679246',
		'secret' => '0d86fb5b91ee8ff74d2e14302949ecd2',
		));
	
	// Get User ID
	$user = $facebook->getUser();
	
	if ($user) 
	{
		try 
		{
			// Proceed knowing you have a logged in user who's authenticated.
			$user_profile = $facebook->api('/me');
		} catch (FacebookApiException $e) {
			error_log($e);
			$user = null;
		}
	}
	
	if ($user) {
		$logoutUrl = $facebook->getLogoutUrl();
	} else {
		$loginUrl = $facebook->getLoginUrl();
	}
?>

<html class = "default">
	<link rel="stylesheet" type="text/css" href="styles/solidblockmenu.css" />
	<link rel="stylesheet" type="text/css" href="styles/master.css" />
	
	<script type="text/javascript" src="javascript/ddtabmenu.js"></script>
	<script type="text/javascript" src="javascript/facebook-login.js"></script>
	
	<head>
	<title><?php echo $pagetitle; ?></title>	
	</head>
	
	<div id="header" >
		<div id = "company_logo" class = "small_border " ></div>
		<h1 id = "sitename">Volunteer Organizers Website (VOW)</h1>
	</div>
	
	<div id = "content" class = "center border"> 
		<div id="mainmenu" class="solidblockmenu border">
		<ul>
			<li><a href="index.php" rel="sb1">Home</a></li>
			<li><a href="" rel="sb2">About Us</a></li>
			<li><a href="" rel="sb3">Donate</a></li>
			<li><a href="">Volunteers</a></li>
			<?php if ($user	 )
			{
				if ($user_profile['id'] == "9613409" ) //My ID!
					{
						echo "<li><a href='manager.php' rel='sb3'>Manage Volunteers</a></li>";
					}
			}
			?>
			
		</ul>
			<div class="tabcontainer">			
				<div id="sb1" class="tabcontent">
				Return to the frontpage of VOW.
				</div>			
				<div id="sb2" class="tabcontent">
				Information about our organization.
				</div>				
				<div id="sb3" class="tabcontent">
				Donate to our organization!
				</div>
			</div>
		</div>
		<script type="text/javascript">
		//SYNTAX: ddtabmenu.definemenu("tab_menu_id", integer OR "auto")
		ddtabmenu.definemenu("mainmenu", "auto") //initialize Tab Menu #1 with 1st tab selected
		</script>
		
		<div id=innerpage class="border"><?php echo $pagemaincontent;?></div>
				
		<div id = "sidepane" class = "right border">
			<div id="fb-root"></div>
			<ul>
				<li>
					<?php if ($user): ?> 
						<a href="<?php echo $logoutUrl; ?>">Logout of Facebook</a>	
					<?php else: ?>
						<div class="fb-login-button">Login with Facebook</div>
					<?php endif ?>
				</li>
				<li>
					<?php if ($user): ?>
						<pre>Welcome <?php print_r($user_profile['name']); ?></pre>
				      	<img src="https://graph.facebook.com/<?php echo $user; ?>/picture">
					      
				    <?php else: ?>
						<strong><em>You are not Connected.</em></strong>
				    <?php endif ?>		
				 </li>
			</ul>
		</div>
	</div>
	<footer class = "foot">Copyright 2012-2012 David Freeman.</footer>

</html>